package k.lhl.test

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.fragment_test.*
import kotlinx.android.synthetic.main.item_test.view.*

/**
 * Author:  LuoHaoLun
 * Email :  506503279@qq.com
 * Date  :  2021/3/25
 */
class TestFragment : Fragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return inflater.inflate(R.layout.fragment_test, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val data = mutableListOf<Int>()
        IntRange(0, 20).forEach { data.add(it) }
        listTest.setAdapter(data) {
            tvNum.text = it.toString()
        }

        listTest.setOnLoadListener {
            listTest.postDelayed({
                listTest.onFooterComplete()
            },3000)
        }

        listTest.setOnRefreshListener {
            listTest.postDelayed({
                listTest.onHeaderComplete()
            },3000)
        }

    }
}